﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Collections;

namespace NPMonitor.Web
{
    public static class WebControlExtensions
    {
        public static void BindDataSource(this DropDownList ddl, IList ds, string text, string value)
        {
            ddl.DataSource = ds;

            if (null != text && text != string.Empty)
            {
                ddl.DataTextField = text;
            }
            if (null != value && value != string.Empty)
            {
                ddl.DataValueField = value;
            }
            ddl.DataBind();

            ddl.Items.Insert(0, new ListItem(CommonString.Select, ""));
        } 
    }
}